package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by Tao on 2017/3/27.
 */

public class GiveFlowerTask extends CouponHttpBaseTask {

    private String mUserId;
    private int mFlowerCount;
    public GiveFlowerTask(String userid , int flowerCount ) {
              mUserId = userid;
              mFlowerCount = flowerCount;
    }
    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS,response.getBody());
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        CouponHttpRequest couponHttpRequest = new CouponHttpRequest();
        JSONObject json = new JSONObject();
        json.put("flowerCount",mFlowerCount);
        json.put("userId",mUserId);
        couponHttpRequest.setApiNo(ApiNo.TRANSFLOWER);
        couponHttpRequest.setData(json.toString());
        addRequest(couponHttpRequest);
    }
}
